using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;

namespace Hospital.POCOModel
{
    public partial class HospitalEntity : DbContext
    {
        public HospitalEntity()
            : base("name=HospitalEntity1")
        {
        }

        public virtual DbSet<AdminUser> AdminUser { get; set; }
        public virtual DbSet<Department> Department { get; set; }
        public virtual DbSet<Specialist> Specialist { get; set; }
        public virtual DbSet<Appointment> Appointment { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<AdminUser>()
                .Property(e => e.PhoneNum)
                .IsUnicode(false);

            modelBuilder.Entity<AdminUser>()
                .Property(e => e.Password)
                .IsUnicode(false);

            modelBuilder.Entity<AdminUser>()
                .Property(e => e.Email)
                .IsUnicode(false);

            modelBuilder.Entity<AdminUser>()
                .HasMany(e => e.Appointment)
                .WithOptional(e => e.AdminUser1)
                .HasForeignKey(e => e.AdminUser);

            modelBuilder.Entity<Specialist>()
                .Property(e => e.Name)
                .IsUnicode(false);

            modelBuilder.Entity<Specialist>()
                .Property(e => e.Avatar)
                .IsUnicode(false);

            modelBuilder.Entity<Specialist>()
                .Property(e => e.Category)
                .IsUnicode(false);

            modelBuilder.Entity<Specialist>()
                .Property(e => e.Department)
                .IsUnicode(false);

            modelBuilder.Entity<Specialist>()
                .Property(e => e.TitleName)
                .IsUnicode(false);

            modelBuilder.Entity<Specialist>()
                .Property(e => e.Specialty)
                .IsUnicode(false);

            modelBuilder.Entity<Specialist>()
                .HasMany(e => e.Appointment)
                .WithOptional(e => e.Specialist1)
                .HasForeignKey(e => e.specialist);
        }
    }
}
